//
//  RyueTabBarController.swift
//  RyueWeibo
//
//  Created by jugg on 2016/11/30.
//  Copyright © 2016年 Renyue'husband. All rights reserved.
//

import UIKit


extension RyueTabBarController: RyueTabBarDelegate{
    func didClickComponsButton(){
        print("我是代理")
    }
}

class RyueTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        
        let yueTabbar = RyueTabBar()
        
        yueTabbar.callBack={ [weak self] in
            print(self)
            
        }
        yueTabbar.tabBarDelegate=self
        setValue(yueTabbar, forKey: "tabBar")
        
        
        
        
        addChildViewController(RyueHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(RyueMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(RyueDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(RyueMineTableViewController(), title: "我的", imageName: "tabbar_profile")

            }

   func addChildViewController(_ childController: UIViewController,title: String,imageName: String) {
        
 
    childController.tabBarItem.image=UIImage(named: imageName)
    
    childController.tabBarItem.selectedImage=UIImage(named: imageName+"_selected")?.withRenderingMode(.alwaysOriginal)
    
    childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orange], for: .selected)
    
    childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName:UIFont.systemFont(ofSize: 14)], for: .normal)
    
    childController.title=title
    
    let navi = RyueNaviController(rootViewController: childController)
    
    super.addChildViewController(navi)
    
    
    }
    
 
    
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
